Skip to content

Comments

UN-3403 "structure_formats" makes output for thinking file of coded tool incomplete#340

Merged
Noravee merged 6 commits intomainfrom
fix-structure-format-make-thinking-file-incomplete
Jul 31, 2025
Merged

UN-3403 "structure_formats" makes output for thinking file of coded tool incomplete#340
Noravee merged 6 commits intomainfrom
fix-structure-format-make-thinking-file-incomplete

Conversation

@Noravee
Copy link
Collaborator

@Noravee Noravee commented Jul 30, 2025

Issue

The expected output was:
{'running_cost': '0.00', 'origin': [{'tool': 'MusicNerdPro', 'instantiation_index': 1}, {'tool': 'Accountant', 'instantiation_index': 1}], 'origin_str': 'MusicNerdPro.Accountant'}

But the actual output was:
{'tool': 'Accountant', 'instantiation_index': 1}

This discrepancy occurs because the current logic in JsonStructureParser does not correctly handle nested dictionaries when extracting structured information.

Fix

Update the implementation of JsonStructureParser.parse_structure() to correctly handle and extract nested dictionary structures.

Test

Manually ran music_nerd_pro and verified that the parsed structure now matches the expected format.


return structure

def _extract_delimited_block(self, text: str, delimiters: Dict[str, str]) -> Tuple[Optional[str], str]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New extraction logic.

self.assertIsNotNone(remainder)
self.assertEqual(remainder, "")

def test_json_backtick_nested_no_remainder(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test case for nested dictionary.

Copy link
Collaborator

@d1donlydfink d1donlydfink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see new tests and existing test passing. Nice job.

@Noravee Noravee merged commit 9d53def into main Jul 31, 2025
4 checks passed
@Noravee Noravee deleted the fix-structure-format-make-thinking-file-incomplete branch July 31, 2025 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants